package com.yidu.hbatsft.action;


import com.yidu.hbatsft.domain.AtsEmpCoach;
import com.yidu.hbatsft.domain.AtsRivalResult;
import com.yidu.hbatsft.service.AtsEmpCoachService;
import com.yidu.hbatsft.service.RivalResultSerice;
import com.yidu.privilege.Domain.User;
import com.yidu.utils.Message;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/RivalResult")
public class RivalResult {

    @Resource
    RivalResultSerice rivalSerice ;


    /**
     * 查询全部
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("findAlls")
    @ResponseBody
    public Map<String, Object> findAll(@RequestParam("page") Integer pageNum, @RequestParam("limit") Integer pageSize ,Integer id) {

        System.out.println("cortorller"+pageNum +"   "+pageSize);

        List<AtsRivalResult> list = rivalSerice.findAll(pageNum,pageSize,id);

        int count = rivalSerice.count();


        Map<String, Object> map=new HashMap<String, Object>();


        map.put("code",0);
        map.put("msg","");
        map.put("count",count);
        map.put("data",list);

        return map;

    }


   /**
     * 根据id查询
    * @param resultId
    * @return
    */
    @RequestMapping("findbyid")
    @ResponseBody
    public AtsRivalResult findbyid(Integer resultId){



       return rivalSerice.findbyid(resultId);
    }


    /**
     * 新增
     * @param as
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public Message insert(AtsRivalResult as){
        System.out.println(as+"dfd d a'");
        rivalSerice.insert(as);
        Message m = new Message();
        m.setNum(1);

        return  m;
    }

    /**
     * 修改
     * @param as
     * @return
     */
    @RequestMapping("addOrupdate")
    @ResponseBody
    public Message updateByPrimaryKey(AtsRivalResult as){
        rivalSerice.updateByPrimaryKey(as);
        Message m = new Message();
        m.setNum(1);

        return m;
    }


    /**
     * 删除
     * @param resultId
     * @return
     */
    @RequestMapping("delete")
    @ResponseBody
    public Message delete(Integer resultId){
        System.out.println("=========="+resultId);
        rivalSerice.delete(resultId);
        Message m = new Message();
        m.setNum(1);
        return m;
    }


    /**
     * 批量删除
     * @param ids
     * @return
     */
    @RequestMapping("deleteAll")
    @ResponseBody
    public Message deleteAll(String ids) {
        Message bm = new Message();
        bm.setNum(1);
        rivalSerice.deleteAll(ids);
        bm.setMsg("删除成功!");
        return bm ;
    }







}
